{% load i18n %}
<style>
    .trade-btn{
        cursor: pointer;
        line-height: 1.42857143;
        color: #0e75ee;
        background:none;
        text-decoration: none;
    }
    .table thead tr{
        background: #fff;
    }
</style>
<script id="temp_order_not_login" type="text/html">
                    <br>
                    <br>
                    <br>
                    <h4>&nbsp<h4>
                    <h4 style="text-align:center;">

                        {% trans '请先'%} <a href="/users/login?next=/{%url 'trade'%}" class="login">{% trans '登录' %}</a>  {% trans '后查看' %}
                    </h4>
                    <br>
                    <br>
                    <br>
                    <br>
                    <br>
</script>

<script id="temp_order" type="text/html">
    <table class="table table-hover table-striped gray ">
        <thead>
        <tr>
            <th>{% trans '委托时间' %}</th>
            <th>{% trans '价格' %}(<%=coin1_info.name_upper%>)</th>
            <th>{% trans '委托' %}</th>
            <th class="row">{% trans '剩余' %}(<%=coin0_info.name_upper%>)</th>
            <th>{% trans '金额' %}(<%=coin1_info.name_upper%>)</th>
            <th class="row">{% trans '剩余' %}(<%=coin1_info.name_upper%>)</th>
            <th>{% trans '完成百分比' %}</th>
            <th><div class="f-fr">{% trans '操作' %}</div></th>
        </tr>
        </thead>
        <tbody>
        <% if (jsonobj.length == 0 ){ %>
        <tr>
            <td colspan="7"><p class="green f-center f-fb">{% trans '暂无委托' %}</p></td>
        </tr>
        <% } %>
        <% for(i = 0; i < jsonobj.length; i ++ ){ %>
        <% var info = jsonobj[i] %>
        <% var id = info.id %>
        <% var create_time = $imports.data_format(info.create_time); %>
        <% var left = info.count - info.finish%>
        <% var count = info.count * 1 %>
        <% var left = left.toFixed(4)%>
        <% var percent = ((info.finish/ info.count) * 100).toFixed(4)%>
        <% var amount = info.price * left%>
        <% var left_amount = info.price*left%>
        <% var amount = amount.toFixed(4)%>
        <% var price = info.price *1%>
        <% var order_type = "{% trans '限价买入' %}"%>
        <% class_color = "green"%>
        <% if (info.order_type == '2') { %>
        <% order_type = "{% trans '限价卖出' %}" %>
        <% class_color = "red"%>
        <% }  %>
        <% if (info.order_type == '11') { %>
        <% order_type = "{% trans '市价买入' %}" %>
        <%     amount = info.amount%>
        <%     price = '{% trans '市价'%}'%>
        <%     left_amount = amount - info.finish_amount%>
        <%     left = '-' %>
        <%     percent = ((info.finish_amount/ info.amount) * 100).toFixed(4)%>
        <%     class_color = "green"%>
        <% }  %>
        <% if (info.order_type == '12') { %>
        <%     left_amount = '-'%>
        <%     amount = '-'%>
        <%     price = '{% trans '市价'%}'%>
        <%     order_type = "{% trans '市价卖出' %}" %>
        <%     class_color = "red"%>
        <% }  %>


        <!--tr class="text-<%=class_color%>"-->
        <tr class="<%=class_color%>" id="block_<%=id%>">
            <td class="<%=class_color%>"><%=create_time%></td>
            <td class="<%=class_color%>"><%=price%></td>
            <td class="<%=class_color%>"><%=order_type%></td>
            <td class="<%=class_color%>"><%=left%></td>
            <td class="<%=class_color%>"><%=amount%></td>
            <td class="<%=class_color%>"><%=left_amount%></td>
            <td class="<%=class_color%>"><%=percent%></td>
            <td> <div class="f-fr">
                <a href="javascript:void(0)" class="trade-btn" onclick="on_cancel_order(this)"  data-id="<%=id%>">{% trans '撤销' %}</a>
                </div>
            </td>
        </tr>
        <%}%>
        </tbody>
    </table>
</script>
